package bepviet.android.ui;

import bepviet.android.engine.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class PreparedMail extends Activity{
	private TextView txtback,mailcontent,mailaddress,mailsubject;
	private Button btnsend;
	@Override
	protected void onCreate(Bundle savedInstanceState) {		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.preparedmail);
		txtback = (TextView)findViewById(R.id.txtback_mail);
		mailcontent =(TextView)findViewById(R.id.mailcontent);
		mailaddress =(TextView)findViewById(R.id.mailaddress);
		mailsubject =(TextView)findViewById(R.id.mailsubject);
		btnsend = (Button)findViewById(R.id.btnsend);
		Bundle bundle = getIntent().getExtras();	
		mailcontent.setText(bundle.getString("contentmail"));
		txtback.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				finish();	
			//	Toast.makeText(PreparedMail.this, "fffffffffff", Toast.LENGTH_LONG).show();
			}
		});
		
		btnsend.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {		
		//		Toast.makeText(PreparedMail.this, "fffffffffff", Toast.LENGTH_LONG).show();
				
				Intent intent = new Intent(Intent.ACTION_SEND); 
            	intent.setType("plain/text"); //use this line for testing in the emulator 
            	intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            	//i.setType("message/rfc822") ; // use from live device
            	intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{mailaddress.getText().toString()}); 
            	intent.putExtra(android.content.Intent.EXTRA_SUBJECT,mailsubject.getText()); 
            	intent.putExtra(android.content.Intent.EXTRA_TEXT, mailcontent.getText()); 
            	PreparedMail.this.startActivity(Intent.createChooser(intent, "Select email application."));
			}
		});
		
	}

}
